<!DOCTYPE html>
<html>

	<head>
		<link rel="stylesheet" type="text/css" href="js/bootstarp-table-1.11.1/bootstrap-table.min.css" />
		<link rel="stylesheet" type="text/css" href="js/bootstarp-3.3.7/css/bootstrap.min.css" />
		<!--<link rel="stylesheet" type="text/css" href="css/myAlert.css" />-->
		<script src="js/jquery/jquery-3.2.1.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="js/bootstarp-3.3.7/js/bootstrap.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="js/bootstarp-table-1.11.1/bootstrap-table.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="js/bootstarp-table-1.11.1/bootstrap-table-zh-CN.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="js/bootstrap-table-export.js"></script>
		<script src="js/jquery.form.js"></script>
		<script src="js/tableExport.min.js"></script>
		<script src="js/xlsx.core.min.js"></script>
		<script src="js/FileSaver.min.js"></script>
		<meta charset="UTF-8">
		<title></title>
		<script>
			$(function() { //, headers: { 'x-requested-with': 'XMLHttpRequest' }
				$.ajaxSetup({
					crossDomain: true,
					xhrFields: {withCredentials: true}
				});
			});
		</script>

		
		

	</head>

	<body>
		<div>
			<table id="table" class="table table-hover table-bordered">
			</table>

		</div>
		<!-- Modal -->
		<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
			<div class="modal-dialog" >
				<div class="modal-content" style="width: 1000px;">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
						<h4 class="modal-title" id="myModalLabel">排班编辑</h4>
					</div>
					<div class="modal-body">
						<center>
							<button id="last-week" class="btn btn-primary  glyphicon glyphicon-chevron-left"></button>
							<button id="today" class="btn btn-primary  glyphicon"></button>
							<button id="next-week" class="btn btn-primary glyphicon glyphicon-chevron-right"></button>
						</center>
						<center>

							<input type="text" id="kaishi" readonly="readonly" />----<input type="text" id="end" readonly="readonly" />
							<button id="doc" class="btn btn-primary glyphicon glyphicon-download-alt">
                                   </button>
						</center>
						<form id="myform">
							Ps:(请选择为休息)
							<table id="monitor" border="1" class="table table-hover table-bordered">

								<tr>
									<input hidden="hidden" id="hospital_id" name="companyId" value="" /><!--医院id-->
									<input hidden="hidden" id="enddate" name="endTimeThisWeek" value="" /><!---->
									<input hidden="hidden" id="date" name="start_time_this_week" value="" /><!---->
									<input hidden="hidden" id="id" name="physicianid" value="" /><!--医生id-->
									<input hidden="hidden" id="department_id" name="departmentId" value="" /><!--科室id-->
									<td>姓名</td>
									<td>科室</td>
									<td>日期</td>
									<td id="u"></td>
									<td id="two"></td>
									<td id="three"></td>
									<td id="four"></td>
									<td id="five"></td>
									<td id="preduct"></td>
									<td id="uu"></td>
								</tr>

								<tr>
									<td id="name"></td>
									<td id="dname"></td>
									<td id="forenoon">上午</td>
									<td>
										<select id="a" name="registeredfee_id">
											<option value='0'>--------</option>
										</select>
									</td>
									<td>
										<select id="z" name="registeredfee_id">
											<option value='0'>--------</option>
										</select>
									</td>
									<td>
										<select id="c" name="registeredfee_id">
											<option value='0'>--------</option>
										</select>
									</td>
									<td>
										<select id="d" name="registeredfee_id">
											<option value='0'>--------</option>
										</select>
									</td>
									<td>
										<select id="e" name="registeredfee_id">
											<option value='0'>--------</option>
										</select>
									</td>
									<td>
										<select id="f" name="registeredfee_id">
											<option value='0'>--------</option>
										</select>
									</td>
									<td>
										<select id="g" name="registeredfee_id">
											<option value='0'>--------</option>
										</select>
									</td>
								</tr>
								<tr>
									<td></td>
									<td></td>
									<td id="afternoon">下午</td>
									<td>
										<select id="h" name="registeredfee_id">
											<option value='0'>--------</option>
										</select>
									</td>
									<td>
										<select id="i" name="registeredfee_id">
											<option value='0'>--------</option>
										</select>
									</td>
									<td>
										<select id="j" name="registeredfee_id">
											<option value='0'>--------</option>
										</select>
									</td>
									<td>
										<select id="k" name="registeredfee_id">
											<option value='0'>--------</option>
										</select>
									</td>
									<td>
										<select id="l" name="registeredfee_id">
											<option value='0'>--------</option>
										</select>
									</td>
									<td>
										<select id="m" name="registeredfee_id">
											<option value='0'>--------</option>
										</select>
									</td>
									<td>
										<select id="o" name="registeredfee_id">
											<option value='0'>--------</option>
										</select>
									</td>
								</tr>
								<tr>
									<td></td>
									<td></td>
									<td id="evening">晚上</td>
									<td>
										<select id="p" name="registeredfee_id">
											<option value='0'>--------</option>
										</select>
									</td>
									<td>
										<select id="q" name="registeredfee_id">
											<option value='0'>--------</option>
										</select>
									</td>
									<td>
										<select id="r" name="registeredfee_id">
											<option value='0'>--------</option>
										</select>
									</td>
									<td>
										<select id="s" name="registeredfee_id">
											<option value='0'>--------</option>
										</select>
									</td>
									<td>
										<select id="t" name="registeredfee_id">
											<option value='0'>--------</option>
										</select>
									</td>
									<td>
										<select id="v" name="registeredfee_id">
											<option value='0'>--------</option>
										</select>
									</td>
									<td>
										<select id="w" name="registeredfee_id">
											<option value='0'>--------</option>
										</select>
									</td>
								</tr>
							</table>
					</div>
					<div class="modal-footer">
						<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
						<button type="button"  id="bt" class="btn btn-success">保存编辑</button>
						</form>
					</div>
				</div>
			</div>
		</div>
	</body>
	<script>
			/*
			 * 网页加载
			 * 显示所有医生信息
			 */
			$(function() {


				$('#table').bootstrapTable({
					url: "http://localhost:8091/spec",
					type: "GET",
					pageNumber: "1",
					pageSize: "2",
					search: true, //是否显示表格搜索，此搜索是客户端搜索，不会进服务端，所以，个人感觉意义不大
					strictSearch: true,
					showColumns: true, //是否显示所有的列
					showRefresh: true, //是否显示刷新按钮
					minimumCountColumns: 2, //最少允许的列数 
					clickToSelect: true, //是否启用点击选中行
					height: 500, //行高，如果没有设置height属性，表格自动根据记录条数觉得表格高度
					uniqueId: "ID", //每一行的唯一标识，一般为主键列
					showToggle: true, //是否显示详细视图和列表视图的切换按钮
					cardView: false, //是否显示详细视图
					detailView: false, //是否显示父子表
					showExport: true, //是否显示导出按钮
					buttonsAlign: "right", //按钮位置
					exportTypes: ['excel'], //导出文件类型
//					 xhrFields: { withCredentials: true },
					Icons: 'glyphicon-export',
					dataType: 'json',
					columns: [{
						field: 'id',
						title: '编号'
					}, {
						field: 'true_name',
						title: '姓名'
					}, {
						field: 'department_name',
						title: '科室名称'
					}, {
						field: 'caozuo',
						title: '操作',
						formatter: function(value, yisheng, index) {
							return "<button type='button' class='btn btn-primary   glyphicon glyphicon-pencil ' onclick='sc(" + JSON.stringify(yisheng) + ")' data-toggle='modal' data-target='#myModal'   ></button>"
						}
					}]

				});
				//function fun1(){
					$.ajax({
						type:"get",
						url:"http://localhost:8091/xiala",
						async:true,
						success: function(data) {
						$.each(data, function(i,val) {
							    $("#a").append("<option value='"+val.reg_id+"'>"+val.registeredfee_name+"</option>");
								$("#h").append("<option value='"+val.reg_id+"'>"+val.registeredfee_name+"</option>");
								$("#p").append("<option value='"+val.reg_id+"'>"+val.registeredfee_name+"</option>");
								$("#z").append("<option value='"+val.reg_id+"'>"+val.registeredfee_name+"</option>");
								$("#i").append("<option value='"+val.reg_id+"'>"+val.registeredfee_name+"</option>");
								$("#q").append("<option value='"+val.reg_id+"'>"+val.registeredfee_name+"</option>");
								$("#c").append("<option value='"+val.reg_id+"'>"+val.registeredfee_name+"</option>");
								$("#j").append("<option value='"+val.reg_id+"'>"+val.registeredfee_name+"</option>");
								$("#r").append("<option value='"+val.reg_id+"'>"+val.registeredfee_name+"</option>");
								$("#d").append("<option value='"+val.reg_id+"'>"+val.registeredfee_name+"</option>");
								$("#k").append("<option value='"+val.reg_id+"'>"+val.registeredfee_name+"</option>");
								$("#s").append("<option value='"+val.reg_id+"'>"+val.registeredfee_name+"</option>");
								$("#e").append("<option value='"+val.reg_id+"'>"+val.registeredfee_name+"</option>");
								$("#l").append("<option value='"+val.reg_id+"'>"+val.registeredfee_name+"</option>");
								$("#t").append("<option value='"+val.reg_id+"'>"+val.registeredfee_name+"</option>");
								$("#f").append("<option value='"+val.reg_id+"'>"+val.registeredfee_name+"</option>");
								$("#m").append("<option value='"+val.reg_id+"'>"+val.registeredfee_name+"</option>");
								$("#v").append("<option value='"+val.reg_id+"'>"+val.registeredfee_name+"</option>");
								$("#g").append("<option value='"+val.reg_id+"'>"+val.registeredfee_name+"</option>");
								$("#o").append("<option value='"+val.reg_id+"'>"+val.registeredfee_name+"</option>");
								$("#w").append("<option value='"+val.reg_id+"'>"+val.registeredfee_name+"</option>");
						});
					    }
					});
				//}

			})

			//导出表
			$("#doc").on("click", function() {
				//获取指定日期
				var kaishi = document.getElementById('u').innerHTML;
				document.getElementById('kaishi').value = kaishi;
				
				var id = $("#id").val(); //获取医生id
				var department_id = $("#department_id").val(); //获取科室类型id
				var name = $("#name").text(); //获取医生名字
				var dname = $("#dname").text(); //获取科室名字
				
				//进行导出
				$.ajax({
					type: "post",
					url: "http://127.0.0.1:8099/dc",
					data: {
						"id": id,
						"department_id": department_id,
						"trueName": name,
						"department_name": dname,
						"start_time_this_week": kaishi
					},
					success: $(function(obj) {
						//导出成功后给出提示
						alert("已导入指定文件目录!");
						$('#monitor').bootstrapTable("refresh");
					})
				});
			})

			/*
			 * 编辑排版
			 * yisheng   医生信息
			 */
			function sc(yisheng) {
				
				//上一周 下一周
				var cells = document.getElementById('monitor').getElementsByTagName('td');
				var clen = cells.length;
				var currentFirstDate;
				var formatDate = function(date) {
					var year = date.getFullYear() + '-';
					var month = (date.getMonth() + 1) + '-';
					var day = date.getDate();
					var week = ['星期天', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'][date.getDay()];

					return year + month + day + ' ' + week;
				};
				var addDate = function(date, n) {
					date.setDate(date.getDate() + n);
					return date;
				};
				var setDate = function(date) {
					var week = date.getDay() - 1;
					date = addDate(date, week * -1);
					currentFirstDate = new Date(date);

					for(var i = 0; i < 7; i++) {
						cells[i + 3].innerHTML = formatDate(i == 0 ? date : addDate(date, 1));
					}

				};
				//查询上周排班信息
				document.getElementById('last-week').onclick = function() {
					//获取日期
					setDate(addDate(currentFirstDate, -7));
					var kaishi = document.getElementById('u').innerHTML;
				    var ends=document.getElementById('uu').innerHTML;
				    document.getElementById('kaishi').value = kaishi;
				    var endsp=null;
				    var kais=null;
					if(ends.length<=13){
						endsp=ends.substring(0,9)
					}else{
						endsp=ends.substring(0,10)
					}
					if(kaishi.length<=12){
						kais=kaishi.substring(0,9)
					}else{
						kais=kaishi.substring(0,10)
					}
					//添加或修改时需要字段
					console.log(endsp+"-----"+kais)
					$("#date").val(kaishi);
					var jieshu = document.getElementById('uu').innerHTML;
					document.getElementById('end').value = jieshu;
					//上一周查询
					$.ajax({
						type: "get",
						url: "http://localhost:8091/sp",
						data: {
							"id": yisheng.id,
							"department_id": yisheng.department_id,
							"start_time_this_week": kais,
						    "end_time_this_week":endsp
						},
						dataType: "json",
						success: function(obj) {
							if(obj.length == 0) { //如果返回的数据为空
								alert("上周没有排班信息!")
								$("#a option[value=" +0+ "]").prop("selected", true);
								$("#z option[value=" +0+ "]").prop("selected", true);
								$("#c option[value=" +0+ "]").prop("selected", true);
								$("#d option[value=" +0+ "]").prop("selected", true);
								$("#e option[value=" +0+ "]").prop("selected", true);
								$("#f option[value=" +0+ "]").prop("selected", true);
								$("#g option[value=" +0+ "]").prop("selected", true);
								$("#h option[value=" +0+ "]").prop("selected", true);
								$("#i option[value=" +0+ "]").prop("selected", true);
								$("#j option[value=" +0+ "]").prop("selected", true);
								$("#k option[value=" +0+ "]").prop("selected", true);
								$("#l option[value=" +0+ "]").prop("selected", true);
								$("#m option[value=" +0+ "]").prop("selected", true);
								$("#o option[value=" +0+ "]").prop("selected", true);
								$("#p option[value=" +0+ "]").prop("selected", true);
								$("#q option[value=" +0+ "]").prop("selected", true);
								$("#r option[value=" +0+ "]").prop("selected", true);
								$("#s option[value=" +0+ "]").prop("selected", true);
								$("#t option[value=" +0+ "]").prop("selected", true);
								$("#v option[value=" +0+ "]").prop("selected", true);
								$("#w option[value=" +0+ "]").prop("selected", true);

							} else {
								//如果依次对数据进行填充
								$("#a option[value=" + obj[0].registeredfee_id + "]").prop("selected", true);
								$("#z option[value=" + obj[1].registeredfee_id + "]").prop("selected", true);
								$("#c option[value=" + obj[2].registeredfee_id + "]").prop("selected", true);
								$("#d option[value=" + obj[3].registeredfee_id + "]").prop("selected", true);
								$("#e option[value=" + obj[4].registeredfee_id + "]").prop("selected", true);
								$("#f option[value=" + obj[5].registeredfee_id + "]").prop("selected", true);
								$("#g option[value=" + obj[6].registeredfee_id + "]").prop("selected", true);
								$("#h option[value=" + obj[7].registeredfee_id + "]").prop("selected", true);
								$("#i option[value=" + obj[8].registeredfee_id + "]").prop("selected", true);
								$("#j option[value=" + obj[9].registeredfee_id + "]").prop("selected", true);
								$("#k option[value=" + obj[10].registeredfee_id + "]").prop("selected", true);
								$("#l option[value=" + obj[11].registeredfee_id + "]").prop("selected", true);
								$("#m option[value=" + obj[12].registeredfee_id + "]").prop("selected", true);
								$("#o option[value=" + obj[13].registeredfee_id + "]").prop("selected", true);
								$("#p option[value=" + obj[14].registeredfee_id + "]").prop("selected", true);
								$("#q option[value=" + obj[15].registeredfee_id + "]").prop("selected", true);
								$("#r option[value=" + obj[16].registeredfee_id + "]").prop("selected", true);
								$("#s option[value=" + obj[17].registeredfee_id + "]").prop("selected", true);
								$("#t option[value=" + obj[18].registeredfee_id + "]").prop("selected", true);
								$("#v option[value=" + obj[19].registeredfee_id + "]").prop("selected", true);
								$("#w option[value=" + obj[20].registeredfee_id + "]").prop("selected", true);
							}

						}
					});

				};
				
				
				
				
				//查询下周医生排班表
				document.getElementById('next-week').onclick = function() {
					setDate(addDate(currentFirstDate, 7));
					var kaishi = document.getElementById('u').innerHTML;
				    var ends=document.getElementById('uu').innerHTML;
				    document.getElementById('kaishi').value = kaishi;
				    
				    var endsp=null;
				    var kais=null;
					if(ends.length=11){
						endsp=ends.substring(0,8)
					}if(ends.length=12){
						endsp=ends.substring(0,9)
					}else{
						endsp=ends.substring(0,10)
					}
					
					if(kaishi.length=11){
						kais=kaishi.substring(0,8)
					}if(kaishi.length=12){
						kais=kaishi.substring(0,9)
					}else{
						kais=kaishi.substring(0,10)
					}
					//添加或修改时需要字段
					$("#date").val(kaishi);
					var jieshu = document.getElementById('uu').innerHTML;
					document.getElementById('end').value = jieshu;
					$.ajax({
						type: "get",
						url: "http://localhost:8091/so",
						data: {
							"id": yisheng.id,
							"department_id": yisheng.department_id,
							"start_time_this_week": kais,
						"end_time_this_week":endsp
						},
						dataType: "json",
						success: function(obj) {
							if(obj.length == 0) {
								alert("下周没有排班信息,请进行编辑!")
								$("#a option[value=" +0+ "]").prop("selected", true);
								$("#z option[value=" +0+ "]").prop("selected", true);
								$("#c option[value=" +0+ "]").prop("selected", true);
								$("#d option[value=" +0+ "]").prop("selected", true);
								$("#e option[value=" +0+ "]").prop("selected", true);
								$("#f option[value=" +0+ "]").prop("selected", true);
								$("#g option[value=" +0+ "]").prop("selected", true);
								$("#h option[value=" +0+ "]").prop("selected", true);
								$("#i option[value=" +0+ "]").prop("selected", true);
								$("#j option[value=" +0+ "]").prop("selected", true);
								$("#k option[value=" +0+ "]").prop("selected", true);
								$("#l option[value=" +0+ "]").prop("selected", true);
								$("#m option[value=" +0+ "]").prop("selected", true);
								$("#o option[value=" +0+ "]").prop("selected", true);
								$("#p option[value=" +0+ "]").prop("selected", true);
								$("#q option[value=" +0+ "]").prop("selected", true);
								$("#r option[value=" +0+ "]").prop("selected", true);
								$("#s option[value=" +0+ "]").prop("selected", true);
								$("#t option[value=" +0+ "]").prop("selected", true);
								$("#v option[value=" +0+ "]").prop("selected", true);
								$("#w option[value=" +0+ "]").prop("selected", true);
							} else {
								$("#a option[value=" + obj[0].registeredfee_id + "]").prop("selected", true);
								$("#z option[value=" + obj[1].registeredfee_id + "]").prop("selected", true);
								$("#c option[value=" + obj[2].registeredfee_id + "]").prop("selected", true);
								$("#d option[value=" + obj[3].registeredfee_id + "]").prop("selected", true);
								$("#e option[value=" + obj[4].registeredfee_id + "]").prop("selected", true);
								$("#f option[value=" + obj[5].registeredfee_id + "]").prop("selected", true);
								$("#g option[value=" + obj[6].registeredfee_id + "]").prop("selected", true);
								$("#h option[value=" + obj[7].registeredfee_id + "]").prop("selected", true);
								$("#i option[value=" + obj[8].registeredfee_id + "]").prop("selected", true);
								$("#j option[value=" + obj[9].registeredfee_id + "]").prop("selected", true);
								$("#k option[value=" + obj[10].registeredfee_id + "]").prop("selected", true);
								$("#l option[value=" + obj[11].registeredfee_id + "]").prop("selected", true);
								$("#m option[value=" + obj[12].registeredfee_id + "]").prop("selected", true);
								$("#o option[value=" + obj[13].registeredfee_id + "]").prop("selected", true);
								$("#p option[value=" + obj[14].registeredfee_id + "]").prop("selected", true);
								$("#q option[value=" + obj[15].registeredfee_id + "]").prop("selected", true);
								$("#r option[value=" + obj[16].registeredfee_id + "]").prop("selected", true);
								$("#s option[value=" + obj[17].registeredfee_id + "]").prop("selected", true);
								$("#t option[value=" + obj[18].registeredfee_id + "]").prop("selected", true);
								$("#v option[value=" + obj[19].registeredfee_id + "]").prop("selected", true);
								$("#w option[value=" + obj[20].registeredfee_id + "]").prop("selected", true);
							}

						}
					});

				};
				setDate(new Date());
				var jieshu = document.getElementById('uu').innerHTML;
				var kaishi = document.getElementById('u').innerHTML;
				var ends=document.getElementById('uu').innerHTML;
				document.getElementById('kaishi').value = kaishi;
				    var endsp=null;
				    var kais=null;
					if(ends.length=11){
						endsp=ends.substring(0,8)
					}if(ends.length=12){
						endsp=ends.substring(0,9)
					}else{
						endsp=ends.substring(0,10)
					}
					
					if(kaishi.length<=11){
						kais=kaishi.substring(0,8)
					}if(kaishi.length<=12){
						kais=kaishi.substring(0,9)
					}else{
						kais=kaishi.substring(0,10)
					}
				//    alert(yisheng.companyId)
				$("#hospital_id").val(yisheng.companyId);//诊所id
				$("#enddate").val(jieshu);
				$("#date").val(kaishi);
				console.log($("#enddate").val()+"------"+$("#date").val())
				$("#id").val(yisheng.id);
				$("#department_id").val(yisheng.did);
				$("#name").text(yisheng.true_name);
				$("#dname").text(yisheng.department_name);
				var xingqiyi=$("#u").text()
				var x1=null;
				if(xingqiyi.length=14){
						x1=xingqiyi.substring(0,10)
					}if(xingqiyi.length=13){
						x1=xingqiyi.substring(0,9)
					}else{
						x1=xingqiyi.substring(0,8)
					}
				var xingqier=$("#two").text()
				var x2=null;
				if(xingqier.length=14){
						x2=xingqier.substring(0,10)
					}if(xingqier.length=13){
						x2=xingqier.substring(0,9)
					}else{
						x2=xingqier.substring(0,8)
					}
				var xingqisan=$("#three").text()//two, three, four, five, six, seven.
				var x3=null;
				if(xingqisan.length=14){
						x3=xingqisan.substring(0,10)
					}if(xingqisan.length=13){
						x3=xingqisan.substring(0,9)
					}else{
						x3=xingqisan.substring(0,8)
					}
				var xingqis=$("#four").text()
				var x4=null;
				if(xingqis.length=14){
						x4=xingqis.substring(0,10)
					}if(xingqis.length=13){
						x4=xingqis.substring(0,9)
					}else{
						x4=xingqis.substring(0,8)
					}
				var xingqiwu=$("#five").text()
				var x5=null;
				if(xingqiwu.length=14){
						x5=xingqiwu.substring(0,10)
					}if(xingqiwu.length=13){
						x5=xingqiwu.substring(0,9)
					}else{
						x5=xingqiwu.substring(0,8)
					}
				var xingqil=$("#preduct").text()
				var x6=null;
				if(xingqil.length=14){
						x6=xingqil.substring(0,10)
					}if(xingqil.length=13){
						x6=xingqil.substring(0,9)
					}else{
						x6=xingqil.substring(0,8)
					}
				var xingqiri=$("#uu").text()
				var x7=null;
				if(xingqiri.length=14){
						x7=xingqiri.substring(0,10)
					}if(xingqiri.length=13){
						x7=xingqiri.substring(0,9)
					}else{
						x7=xingqiri.substring(0,8)
					}
				$.ajax({
					type: "get",
					url: "http://localhost:8091/findweek",
					data: {
						"id": yisheng.id,
						"department_id": yisheng.department_id,
						"start_time_this_week": kais,
						"end_time_this_week":endsp
					},
					dataType: "json",
					success: function(obj) {
						if(obj.length == 0) {
							alert("本周暂无数据请排班!")
						} else {
							    $("#a option[value=" + obj[0].registeredfee_id + "]").prop("selected", true);
								$("#z option[value=" + obj[1].registeredfee_id + "]").prop("selected", true);
								$("#c option[value=" + obj[2].registeredfee_id + "]").prop("selected", true);
								$("#d option[value=" + obj[3].registeredfee_id + "]").prop("selected", true);
								$("#e option[value=" + obj[4].registeredfee_id + "]").prop("selected", true);
								$("#f option[value=" + obj[5].registeredfee_id + "]").prop("selected", true);
								$("#g option[value=" + obj[6].registeredfee_id + "]").prop("selected", true);
								$("#h option[value=" + obj[7].registeredfee_id + "]").prop("selected", true);
								$("#i option[value=" + obj[8].registeredfee_id + "]").prop("selected", true);
								$("#j option[value=" + obj[9].registeredfee_id + "]").prop("selected", true);
								$("#k option[value=" + obj[10].registeredfee_id + "]").prop("selected", true);
								$("#l option[value=" + obj[11].registeredfee_id + "]").prop("selected", true);
								$("#m option[value=" + obj[12].registeredfee_id + "]").prop("selected", true);
								$("#o option[value=" + obj[13].registeredfee_id + "]").prop("selected", true);
								$("#p option[value=" + obj[14].registeredfee_id + "]").prop("selected", true);
								$("#q option[value=" + obj[15].registeredfee_id + "]").prop("selected", true);
								$("#r option[value=" + obj[16].registeredfee_id + "]").prop("selected", true);
								$("#s option[value=" + obj[17].registeredfee_id + "]").prop("selected", true);
								$("#t option[value=" + obj[18].registeredfee_id + "]").prop("selected", true);
								$("#v option[value=" + obj[19].registeredfee_id + "]").prop("selected", true);
								$("#w option[value=" + obj[20].registeredfee_id + "]").prop("selected", true);
						}
					}
				});
			}
			//操作添加和修改
			$("#bt").on("click", function() {
				$('#myform').ajaxSubmit({
						url: 'http://localhost:8091/caozuo',
						type: 'GET',
						crossDomain: true,
					     xhrFields: {withCredentials: true},
						dataType: 'json',
						beforeSend: function() {
						}, 
						success: function(data) {
							if(data == "1") {
								alert("添加成功!");
								$('#myModal').modal('hide'); //模态框消失
								$('#table').bootstrapTable("refresh"); //自动刷新
							} else {
								alert("修改成功!");
								$('#myModal').modal('hide'); //模态框消失

								$('#table').bootstrapTable("refresh"); //自动刷新
							}
						},
						clearForm: true, //禁止清楚表单
						resetForm: true //禁止重置表单
					});
			});
			//模态框消失事件
			$('#myModal').on('hidden.bs.modal', function() {
				//当模态框消失以后所有文本框清空数据
				$("#a option[value=" + 0 + "]").prop("selected", true);
				$("#h    option[value=" + 0 + "]").prop("selected", true);
				$("#p option[value=" + 0+ "]").prop("selected", true);
				$("#z option[value=" + 0 + "]").prop("selected", true);
				$("#i option[value=" + 0 + "]").prop("selected", true);
				$("#q option[value=" + 0 + "]").prop("selected", true);
				$("#c option[value=" + 0 + "]").prop("selected", true);
				$("#j option[value=" + 0 + "]").prop("selected", true);
				$("#r option[value=" + 0 + "]").prop("selected", true);
				$("#d option[value=" + 0 + "]").prop("selected", true);
				$("#k option[value=" + 0 + "]").prop("selected", true);
				$("#s option[value=" + 0 + "]").prop("selected", true);
				$("#e option[value=" + 0 + "]").prop("selected", true);
				$("#l option[value=" + 0 + "]").prop("selected", true);
				$("#t option[value=" + 0 + "]").prop("selected", true);
				$("#f option[value=" + 0 + "]").prop("selected", true);
				$("#m option[value=" + 0 + "]").prop("selected", true);
				$("#v option[value=" + 0 + "]").prop("selected", true);
				$("#g option[value=" + 0 + "]").prop("selected", true);
				$("#o option[value=" + 0 + "]").prop("selected", true);
				$("#w option[value=" + 0 + "]").prop("selected", true);
				$("#kaishi").val("");
				$("#end").val("");

			});
		</script>

</html>